#include "entity.h"
#include "stack.h"


int main(int argc, char** argv)
{

	char readBuf[128] = {0};
	
	FILE* fin;
	

	fin = fopen("./data.txt", "rt");

	if(fin==NULL)
	{
		fprintf(stderr, "open file error...%s\n", "./data.txt");
		exit(1);
	}

	struct Stack* pstack = createStack(20, 
									   _cpData,
									   _printInfo,
									   _myDataSize,
									   _getPointer);

	struct Data data;
	memset((void*)&data, 0, sizeof(data));

	while(fgets(readBuf, 127, fin )!=NULL)
	{
		struct Data data;
		memset((void*)&data, 0, sizeof(data));
		data.tmp = atoi(strtok(readBuf, " "));
		const char* ci = strtok(NULL, " ");
		memcpy(&data.city, ci, strlen(ci)>20?19:strlen(ci));
		pushElement(pstack, &data);
	}

	printInfo(pstack);
	deleteStack(pstack);
	getchar();
	exit(0);
}
